Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fragile fix for: Singleton client API not yet initialized #254

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

bfanger
Copy link
Contributor

@bfanger bfanger commented Feb 22, 2022

To paraphase yarnpkg/berry#4122

@storybook/client-api peer depends on react.

@storybook/svelte@6.4.3 depends on @storybook/client-api and react@16.14.0, but your workspaces depend on @storybook/client-api and react@17.0.2.

yarn why -R @storybook/client-api
yarn why -R react

Thats why Yarn has to create two copies of @storybook/client-api: the first copy which uses react@16.14.0 and the other copy which uses react@17.0.2


I've had little succes with the proposed packageExtensions solution, but after some mucking around with yarn why -R command, I discovered that downgrading React to the same version and pinning the storybook version in example-react-ts to same version as the other packages (6.4.14) was enough to dedupe the @storybook/client-api package.

Fixes #50 but its a fragile fix, when upgrading or adding dependencies the issue can resurface.

@storybook/client-api peer depends on react.

@storybook/svelte@6.4.3 depends on @storybook/client-api and react@16.14.0. But your workspaces depend on @storybook/client-api and react@17.0.2.

yarn why -R @storybook/client-api
yarn why -R react

Thats why Yarn has to create two copies of @storybook/client-api: the first copy which uses react@16.14.0 and the other copy which uses react@17.0.2
Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing sleuthing, thanks a ton!

@IanVS IanVS requested a review from joshwooding February 22, 2022 21:47
Copy link
Member

@joshwooding joshwooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one :)

@joshwooding joshwooding merged commit a459195 into storybookjs:main Feb 23, 2022
@joshwooding
Copy link
Member

Thanks @bfanger :)

@Enteleform
Copy link

@bfanger What config did you try with packageExtensions?

Found your thread @ the Yarn repo & it helped me resolve a similar issue with astro & solid-js. Just posted @ yarnpkg/berry#4122 (comment).

@larixer
Copy link

larixer commented Feb 23, 2022

@bfanger

I've had little succes with the proposed packageExtensions solution

The packageExtension solution should be done the following way, the lines below should be added to the .yarnrc.yml:

packageExtensions:
  "@storybook/svelte@*":
    peerDependencies:
      react: "*"
      react-dom: "*"
  "@storybook/vue3@*":
    peerDependencies:
      react: "*"
      react-dom: "*"

This will force @storybook/svelte and @storybook/vue3 to peerDepend on react and react-dom. But this is not enough, their parent packages should provide these dependencies. So packages/example-svelete/package.json and packages/example-vue/package.json should have the following lines in their dependencies field:

  "dependencies": {
    ...
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught Error: Singleton client API not yet initialized, cannot call addParameters
5 participants